package xmlparser;

/**
 *
 * @author pbelov
 */
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.*;

public class infoParser extends DefaultHandler{

    int lastBug;

    String thisElement = "";

    public static String LAST_BUG = "last_bug";

    public infoParser() {
    }

    public int getLastBug(){
        return lastBug;
    }

    @Override
    public void startDocument() throws SAXException {
      System.out.println("Start parse info XML...");
    }

    @Override
    public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
        thisElement = qName;
    }

    @Override
    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
        thisElement = "";
    }

    @Override
    public void characters(char[] ch, int start, int length) throws SAXException {
        if (thisElement.equals(LAST_BUG)) {
            lastBug = Integer.parseInt(new String(ch, start, length));
        }
    }

    @Override
    public void endDocument() {
        System.out.println("Stop parse info XML...");
    }
}


